<template>
  <el-table :data="users" style="width: 100%">
    <el-table-column label="日期" width="180">
      <template slot-scope="scope">
        <i class="el-icon-time"></i>
        <span style="margin-left: 10px">{{ scope.row.ratingTime }}</span>
      </template>
    </el-table-column>
     <el-table-column label="评价人" width="180">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.userID.realName }}</span>
      </template>
    </el-table-column>
     <el-table-column label="评分" width="180">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.score }}</span>
      </template>
    </el-table-column>
     <el-table-column label="评价内容" width="180">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.content }}</span>
      </template>
    </el-table-column>
    <el-table-column label="被评人ID" width="200">
      <template slot-scope="scope">
        <el-popover :data="ser" >
          <p>姓名: {{ ser.realName }}</p>
          <p>电话: {{ ser.phone }}</p>
          <div slot="reference" class="name-wrapper" @click="getUsers(scope.row.usersID)">
            <el-tag size="medium">{{ scope.row.usersID }}</el-tag>
          </div>
        </el-popover>
      </template>
    </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          size="mini"
          type="danger"
          @click="handleDelete( scope.row._id)"
          >删除</el-button
        >
      </template>
     
    </el-table-column>
  </el-table>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapActions, mapState,mapMutations } = createNamespacedHelpers("customerComments");
const { mapMutations:publickMutations }= createNamespacedHelpers('publicStore')
export default {
  data() {
    return {
      ser:{},
    };
  },
  created() {
    this.getUserComment();
    this.setNowBreadcrumb('usersList')
  },
  watch:{
    async sers(ss){
      this.ser = ss;
    },
  },
  computed: {
    ...mapState(["users", "userID","sers"]),
  },
  methods: {
    ...publickMutations(['setNowBreadcrumb']),
    ...mapActions(["getUserComments","getUser","deletComments"]),
    getUserComment() {
      this.getUserComments();
    },
    getUsers(_id){
        this.getUser(_id)
      
    },
    handleDelete(_id) {
      //删除
      this.deletComments(_id)
      this.getUserComment();
    },
  },
};
</script>

<style>
</style>